home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / BoxOut fade.c < prev    next >
Text File  |  1994-04-15  |  2KB  |  61 lines

  1. /**********************************************************************\
  2.  
  3. File:        BoxOut fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define        BOXES    50    /* increase this for a finer grained but more timely effect */
  28. #define CorrectTime 2
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  31.  
  32. pascal short BoxOutFade(Rect boundsRect, Pattern *thePattern);
  33.  
  34. pascal short BoxOutFade(Rect boundsRect, Pattern *thePattern)
  35. {
  36.     Rect    theRect;
  37.     int        cenx, ceny;
  38.     int        boxnum;
  39.     
  40.     cenx = theWindowWidth / 2;
  41.     ceny = theWindowHeight / 2;
  42.     
  43.     for(boxnum = 0; boxnum <= BOXES; boxnum++)
  44.     {
  45.         StartTiming();
  46.         
  47.         /* this is not the most efficient method, but the overhead of the
  48.         multiplies and the redundant copying is hidden by the timing mechanism */
  49.         theRect.left = cenx - ((boxnum * cenx) / BOXES);
  50.         theRect.right = cenx + ((boxnum * cenx) / BOXES);
  51.         theRect.top = ceny - ((boxnum * ceny) / BOXES);
  52.         theRect.bottom = ceny + ((boxnum * ceny) / BOXES);
  53.         OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  54.         
  55.         FillRect(&theRect, *thePattern);
  56.         TimeCorrection(CorrectTime);
  57.     }
  58.     
  59.     return 0;
  60. }
  61.